home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000…tember: Reference Library / Dev.CD Sep 00 RL Disk 1.toast / mac / Technical Documentation / Develop / develop Issue 28 / develop Issue 28 code / MacApp Debugging / TwistDownLists / UTwistDownDocument.h < prev    next >
Encoding:
Text File  |  1996-07-15  |  11.5 KB  |  276 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UTwistDownDocument.h
  3. // ETO20 MacApp 3.3.1, MPW 3.4.1
  4. // Copyright ©1994-1996 Conrad Kopala
  5. // Twist Down Lists version 2.0a0 7/15/96
  6. //----------------------------------------------------------------------------------------
  7.  
  8. #ifndef __UTWISTDOWNDOCUMENT__
  9. #define __UTWISTDOWNDOCUMENT__
  10.  
  11. #ifndef __UVOLUME__
  12. #include "UVolume.h"
  13. #endif
  14.  
  15. //Required to get ESearchMethod
  16. #ifndef __UTWISTDOWNGLOBALS__
  17. #include "UTwistDownGlobals.h"
  18. #endif
  19.  
  20. //MacApp stuff
  21. #ifndef __UDOCUMENT__
  22. #include "UDocument.h"
  23. #endif
  24.  
  25. //ToolBox stuff
  26. //None
  27.  
  28. //ANSI stuff
  29. //None
  30. //----------------------------------------------------------------------------------------
  31. // Constants
  32. //----------------------------------------------------------------------------------------
  33.  
  34. //----------------------------------------------------------------------------------------
  35. // Externals
  36. //----------------------------------------------------------------------------------------
  37.  
  38. class TTwistDownApp;                        //external
  39. class TTwistDownView;                        //external
  40. class TTwistDownElement;                //external
  41. class TTwistDownControl;                //external
  42. class TProgressBarIndicator;        //external
  43. class TTwistDownDocument;                //forward
  44.  
  45. //----------------------------------------------------------------------------------------
  46. // TExpandAllCommand
  47. //----------------------------------------------------------------------------------------
  48. class TExpandAllCommand: public TServerCommand
  49. {
  50.     MA_DECLARE_CLASS;
  51.     
  52. public:
  53. TTwistDownView* fTwistDownView;
  54. TTwistDownDocument* fTwistDownDocument;
  55. //The following two fields will be used for error recovery.
  56. long fOldNumberOfExpandedControls;
  57. long fOldNumberOfCollapsedControls;
  58.  
  59. TExpandAllCommand::TExpandAllCommand();
  60. virtual ~TExpandAllCommand();
  61.  
  62. void TExpandAllCommand::IExpandAllCommand(TTwistDownDocument* twistDownDocument, TCommandHandler* itsContext);                                                                                
  63. void TExpandAllCommand::IExpandAllCommand(TTwistDownDocument* twistDownDocument, TCommandHandler* itsContext, 
  64.                                                                                     const AppleEvent& itsMessage, const AppleEvent& itsReply);
  65. virtual TAppleEvent* TExpandAllCommand::MakeAppleEvent(); 
  66. virtual void TExpandAllCommand::DoIt();
  67. };
  68. //----------------------------------------------------------------------------------------
  69. // TCollapseAllCommand
  70. //----------------------------------------------------------------------------------------
  71. class TCollapseAllCommand: public TServerCommand
  72. {
  73.     MA_DECLARE_CLASS;
  74.     
  75. public:
  76. TTwistDownView* fTwistDownView;
  77. TTwistDownDocument* fTwistDownDocument;
  78.  
  79. TCollapseAllCommand::TCollapseAllCommand();
  80. virtual ~TCollapseAllCommand();
  81.  
  82. void TCollapseAllCommand::ICollapseAllCommand(TTwistDownDocument* twistDownDocument, TCommandHandler* itsContext);
  83. void TCollapseAllCommand::ICollapseAllCommand(TTwistDownDocument* twistDownDocument, TCommandHandler* itsContext, 
  84.                                                                                         const AppleEvent& itsMessage, const AppleEvent& itsReply);
  85. virtual TAppleEvent* TCollapseAllCommand::MakeAppleEvent(); 
  86. virtual void TCollapseAllCommand::DoIt();
  87. };
  88. //----------------------------------------------------------------------------------------
  89. // TExpandElementCommand
  90. //----------------------------------------------------------------------------------------
  91. class TExpandElementCommand: public TServerCommand
  92. {
  93.     MA_DECLARE_CLASS;
  94.     
  95. public:
  96. TTwistDownDocument* fTwistDownDocument;
  97. TTwistDownView* fTwistDownView;
  98. TTwistDownElement* fElementToExpand;
  99.  
  100. //The following two fields will be used for error recovery.
  101. long fOldNumberOfExpandedControls;
  102. long fOldNumberOfCollapsedControls;
  103.  
  104. TExpandElementCommand::TExpandElementCommand();
  105. virtual ~TExpandElementCommand();
  106. void TExpandElementCommand::IExpandElementCommand(TTwistDownDocument* twistDownDocument, 
  107.                                                     TTwistDownElement* elementToExpand);
  108. void TExpandElementCommand::IExpandElementCommand(TTwistDownDocument* twistDownDocument, 
  109.                                                     TTwistDownElement* elementToExpand, const AppleEvent& itsMessage, 
  110.                                                                             const AppleEvent& itsReply);                                                
  111. virtual TAppleEvent* TExpandElementCommand::MakeAppleEvent(); 
  112. virtual void TExpandElementCommand::DoIt();
  113. };
  114. //----------------------------------------------------------------------------------------
  115. // TCollapseElementCommand
  116. //----------------------------------------------------------------------------------------
  117. class TCollapseElementCommand: public TServerCommand
  118. {
  119.     MA_DECLARE_CLASS;
  120.     
  121. public:
  122. TTwistDownDocument* fTwistDownDocument;
  123. TTwistDownView* fTwistDownView;
  124. TTwistDownElement* fElementToCollapse;
  125.  
  126. TCollapseElementCommand::TCollapseElementCommand();
  127. virtual ~TCollapseElementCommand();
  128. void TCollapseElementCommand::ICollapseElementCommand(TTwistDownDocument* twistDownDocument, 
  129.                                                         TTwistDownElement* elementToCollapse);
  130. void TCollapseElementCommand::ICollapseElementCommand(TTwistDownDocument* twistDownDocument, 
  131.                                                     TTwistDownElement* elementToCollapse, const AppleEvent& itsMessage, 
  132.                                                                             const AppleEvent& itsReply);                                                            
  133. virtual TAppleEvent* TCollapseElementCommand::MakeAppleEvent(); 
  134. virtual void TCollapseElementCommand::DoIt();
  135.  
  136. };
  137. //----------------------------------------------------------------------------------------
  138. // TTwistDownDocument
  139. //----------------------------------------------------------------------------------------
  140. class TTwistDownDocument: public TDocument
  141. {
  142.     MA_DECLARE_CLASS;
  143.     
  144. public:
  145. TVolume* fVolume;
  146. short fVolumeRefNumber;
  147. CStr31 fVolumeName;
  148. short fSameVolumeNumber;    //Used by TTwistDownApp::GetNextDocumentNumber to make
  149.                                                     //sure document numbers aren't duplicated.
  150. Boolean fShowInvisibleFiles;
  151. Boolean fEnableProgressIndicatorStop;
  152.  
  153. TSimpleDependencySpace* fDependencies;
  154.  
  155. long fNumberOfDirectoriesToLoad;
  156. long fNumberOfFilesToLoad;
  157. long fNumberOfItemsToLoad;
  158.  
  159. // The user can stop loading the list early. I want to know how many of each kind of thing
  160. // are actually in the list. The following three fields are used to keep count of the number
  161. // of things of each kind that are actually in the list. The three previous fields could have been
  162. // recycled but, I think this is clearer and I want to be able to read this code a year from now
  163. // without having to spend anymore time figuring it out than is necessary.
  164. long fNumberOfDirectoriesInList;
  165. long fNumberOfFilesInList;
  166. long fNumberOfItemsInList;
  167.  
  168. TTwistDownView* fTwistDownView;
  169. TTwistDownElement* fHeadOfListElement;
  170. TextStyle fTextStyle;
  171.  
  172. TProgressBarIndicator* fProgressBarIndicator;
  173. long fUpdateAmount;
  174. long fProgressUpdateCounter;
  175.  
  176. ESearchMethod fSearchMethod;
  177.  
  178. TTwistDownDocument::TTwistDownDocument(); 
  179. virtual ~TTwistDownDocument();
  180.  
  181. void  TTwistDownDocument::ITwistDownDocument(TVolume* itsVolume, Boolean showInvisibleFiles);
  182.  
  183. virtual void  TTwistDownDocument::CloseAndFree();
  184.  
  185. virtual TDependencySpace* TTwistDownDocument::GetDependencySpace();
  186. virtual void TTwistDownDocument::Changed(ChangeID theChange, TObject* changedBy);
  187.  
  188. Boolean TTwistDownDocument::FindDocument(TVolume* aVolume);
  189. void TTwistDownDocument::SetVolumeData(short volumeRefNumber, CStr31 volumeName);
  190. void TTwistDownDocument::SetUpdateAmountTo(long updateAmount);
  191.  
  192. virtual void  TTwistDownDocument::FreeData();
  193. void TTwistDownDocument::FreeTwistDownList(TTwistDownElement* twistDownElement);
  194.  
  195. virtual void  TTwistDownDocument::DoMakeViews(Boolean forPrinting);
  196. void TTwistDownDocument::AddPrintHandlerToView(TView* aView);
  197.  
  198. virtual void TTwistDownDocument::DoSetupMenus();
  199.  
  200. virtual void TTwistDownDocument::ReadDocument(Boolean forPrinting); //overloaded
  201. virtual void TTwistDownDocument::DoPostMakeViews(Boolean forPrinting);
  202.  
  203. TTwistDownElement* TTwistDownDocument::BuildTwistDownList(short indentLevel,
  204.                                                 long volumeDirIndex, OSErr& myOSErr);
  205.                                                 
  206. TTwistDownElement* TTwistDownDocument::MakeTwistDownElement(TTwistDownElement* previousElement,short indentLevel,
  207.                                                 CStr63 displayedText, OSErr& myOSErr);
  208.  
  209. void TTwistDownDocument::DisposeTwistDownElement(TTwistDownElement* twistDownElement);
  210.  
  211. //CountVisibleElements counts all twistDownElements in the visible list (ie. fShowSubList == TRUE).
  212. //That includes both successor and descendant elements. Usually, fHeadOfListElement is
  213. //passed to CountVisibleElements. Be sure you really want to start counting with some other element.
  214. long TTwistDownDocument::CountVisibleElements(TTwistDownElement* twistDownElement);
  215.  
  216. void TTwistDownDocument::GetTwistDownElementAt(short anItem, TTwistDownElement* startingTwistDownElement, 
  217.                                                             TTwistDownElement** currentTwistDownElement, short &rowNumber);
  218.  
  219. void TTwistDownDocument::GetTwistDownElementRowNumber(TTwistDownElement* startingTwistDownElement, 
  220.                                                             TTwistDownElement* targetTwistDownElement,
  221.                                                             TTwistDownElement** currentTwistDownElement, short &rowNumber);
  222.                                                             
  223. TTwistDownElement* TTwistDownDocument::GetHeadOfList();
  224.  
  225. void TTwistDownDocument::ExpandElement(TTwistDownElement* twistDownElementToExpand);
  226. void TTwistDownDocument::CollapseElement(TTwistDownElement* twistDownElementToCollapse);
  227.  
  228. void TTwistDownDocument::SetShowSubListFlags(TTwistDownElement* twistDownElement);
  229. void TTwistDownDocument::ClearShowSubListFlags(TTwistDownElement* twistDownElement);
  230. void TTwistDownDocument::RestoreShowSubListFlags(TTwistDownElement* twistDownElement);
  231.  
  232. void TTwistDownDocument::CollapseAll();
  233.  
  234. void TTwistDownDocument::InstallTextStyle(const TextStyle& itsTextStyle);
  235. void TTwistDownDocument::UpdateTwistDownElements(TTwistDownElement* twistDownElement, short &rowNumber);                             
  236. void TTwistDownDocument::CalculateColWidthParams(TTwistDownElement* twistDownElement, short& maxIndentLevel, 
  237.                                                                                                                                                 short& maxTextWidth);                             
  238.  
  239. void  TTwistDownDocument::IncrementItemsInList();
  240. void  TTwistDownDocument::DecrementItemsInList();
  241.  
  242. long TTwistDownDocument::GetNumberOfDirectoriesInList();
  243. long TTwistDownDocument::GetNumberOfItemsInList();
  244.  
  245. //Scripting Support
  246. virtual void TTwistDownDocument::DoScriptCommand(CommandNumber aCommandNumber,TAppleEvent* message,TAppleEvent* reply);
  247. void TTwistDownDocument::GetTwistDownElementByName(TTwistDownElement* startingTwistDownElement, 
  248.                                                             TTwistDownElement** currentTwistDownElement, CStr63 &theName, Boolean &foundIt);
  249.  
  250. void TTwistDownDocument::GetTwistDownElementByIndex(short desiredIndex, TTwistDownElement* startingTwistDownElement, 
  251.                                                             TTwistDownElement** currentTwistDownElement, short &elementCounter);
  252.  
  253. void TTwistDownDocument::GetVisibleTwistDownElementByName(TTwistDownElement* startingTwistDownElement, 
  254.                                                             TTwistDownElement** currentTwistDownElement, CStr63 &theName, Boolean &foundIt);
  255.  
  256. void TTwistDownDocument::GetVisibleTwistDownElementByIndex(short desiredIndex, TTwistDownElement* startingTwistDownElement, 
  257.                                                             TTwistDownElement** currentTwistDownElement, short &elementCounter);
  258.                                                             
  259. virtual Boolean TTwistDownDocument::GetObjectProperty(CAEDesc& thePropertyValue,DescType whichProperty,
  260.                                                                         const CAEDesc& desiredType);
  261.                                                                         
  262. virtual void TTwistDownDocument::GetSetPropertyInfo(DescType whichProperty,CommandNumber& cmdNum,Boolean& canUndo,
  263.                                                             Boolean& causesChange,TCommandHandler* &theContext);
  264.                                 
  265. virtual void TTwistDownDocument::SetObjectProperty(const CAEDesc& thePropertyValue,DescType whichProperty);
  266.  
  267. virtual MScriptableObject* TTwistDownDocument::GetIndContainedObject(DescType desiredType,long index);
  268.  
  269. virtual MScriptableObject* TTwistDownDocument::GetContainedObject(DescType desiredType,DescType selectionForm, 
  270.                                                             const CAEDesc& selectionData);
  271.                                                             
  272. virtual long TTwistDownDocument::CountContainedObjects(DescType desiredType);
  273. };
  274.  
  275. #endif
  276.